package com.example.administrator.yuejian_15.activity;

import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;


import com.example.administrator.yuejian_15.R;
import com.example.administrator.yuejian_15.adapter.JlbKcAdapter;
import com.example.administrator.yuejian_15.bean.JlbKcBean;
import com.example.administrator.yuejian_15.listener.ListListener;
import com.example.administrator.yuejian_15.model.JlbKcModel;

import java.util.List;

public class JlbKcActivity extends BaseActivity implements View.OnClickListener {

    ImageView kc_fh;
    RecyclerView rv_kclist;
    String jlbid;
    List<JlbKcBean> items;


    @Override
    void initView() {
        setLayout_file(R.layout.activity_jlb_kc);
        jlbid=getIntent().getStringExtra("jlbid");
        kc_fh=(ImageView)findViewById(R.id.kc_fh);
        rv_kclist=(RecyclerView)findViewById(R.id.rv_kclist);
        JlbKcModel jlbKcModel = new JlbKcModel();
        jlbKcModel.getKcList(jlbid,jlbKcBeanListListener);

    }

    @Override
    void initEvent() {
        kc_fh.setOnClickListener(this);
    }

    @Override
    void initDate() {

    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.kc_fh:
                finish();
                break;
        }

    }

    ListListener<JlbKcBean> jlbKcBeanListListener = new ListListener<JlbKcBean>() {
        @Override
        public void onResponse(List<JlbKcBean> list) {

            LinearLayoutManager linearLayoutManager=new LinearLayoutManager(JlbKcActivity.this);
            linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
            rv_kclist.setLayoutManager(linearLayoutManager);
            items=list;
            JlbKcAdapter jlbkcAdapter=new JlbKcAdapter(JlbKcActivity.this,items,R.layout.item);
            rv_kclist.setAdapter(jlbkcAdapter);
            rv_kclist.setItemAnimator(new DefaultItemAnimator());

        }

        @Override
        public void onFail(String msg) {

        }
    };
}
